package com.kunteng.ynhxksh.util;

import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Created By ShiYun with IntelliJ IDEA on 2018/4/3 15:28
 *
 * @author: ShiYun
 * @Email: 515867726@qq.com
 * @Date: 2018/4/3
 * To change this template use File | Settings | File Templates.
 */
public class DateUtils {

    private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

    private static SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");


    private static DecimalFormat df = new DecimalFormat("0.00%");

    public static String getDate_yyyy_MM_dd(Date date) {
        return sdf.format(date);
    }

    public static String getDate_yyyy_MM_dd_HH_mm_ss(Date date) {
        return sdf1.format(date);
    }

    public static String getBFB(double data) {
        return df.format(data);
    }

    public static void main(String[] args) {

        for (int i = 0; i < 7; i++) {
            Calendar calendar = Calendar.getInstance();
            calendar.add(Calendar.DATE, -i);
            System.out.println(sdf.format(calendar.getTime()));
        }

        DecimalFormat df = new DecimalFormat("0.00%");
        System.out.println(df.format(0.123456));
    }
}
